package com.xm.xmapp;

import java.util.ArrayList;

import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;

import com.astuetz.PagerSlidingTabStrip;
import com.xm.xmapp.adapter.MyPagerAdapters;
import com.xm.xmapp.base.BaseActivity;
import com.xm.xmapp.fragment.LongRentOrderFragment;
import com.xm.xmapp.fragment.PileOrderFragment;
import com.xm.xmapp.fragment.ShortTimeOrderFragment;
import com.xm.xmapp.tools.AndroidTool;
import com.xm.xmapp.tools.Tools;

public class MyOrderActivity extends BaseActivity{

	private TabLayout tab;
	private ViewPager vp;
	private MyPagerAdapters adapter;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_myorder);
	}

	@Override
	public void initView() {
		vp = (ViewPager) findViewById(R.id.vp);
		tab = (TabLayout) findViewById(R.id.tab);
	}

	@Override
	public void initData() {

		setMyTitle("我的订单");
		String[] title = { "分    时", "长    时", "充    电" };
		adapter = new MyPagerAdapters(title, getSupportFragmentManager(),
				new ArrayList<Fragment>());
		ShortTimeOrderFragment timeOrderFrament = new ShortTimeOrderFragment();
		timeOrderFrament.setType(0);
		LongRentOrderFragment longRentOrderFrament = new LongRentOrderFragment();
		longRentOrderFrament.setType(1);
		PileOrderFragment pileOrderFrament = new PileOrderFragment();	
		
		adapter.fragmentsList.add(timeOrderFrament);
		adapter.fragmentsList.add(longRentOrderFrament);
		adapter.fragmentsList.add(pileOrderFrament);
		// 设置tab选中底部颜色
		// 设置Viewpage属性
		vp.setAdapter(adapter);
		vp.setOffscreenPageLimit(3);
		// 关联ViewPage
		tab.setupWithViewPager(vp);
		tab.post(new Runnable() {
			@Override
			public void run() {
				int marig = Tools.dp2px(10);
				AndroidTool.setIndicator(tab,marig,marig);
			}
		});
	}

	

	@Override
	public void initEvent() {

	}


}
